//
//  ViewController.swift
//  Jisuanqi
//
//  Created by shenboren on 2017/9/25.
//  Copyright © 2017年 shenboren. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var input1: UITextField!
    @IBOutlet weak var input2: UITextField!
    @IBOutlet weak var result: UITextField!
    @IBOutlet weak var add: UIButton!
    @IBOutlet weak var sub: UIButton!
    @IBOutlet weak var mul: UIButton!
    @IBOutlet weak var div: UIButton!
    
    @IBAction func addCal(_ sender: UIButton) {
        let str1 = input1.text!
        let str2 = input2.text!
        var resultInt = 0
        let title = sender.currentTitle!
        switch title {
        case "加":
            resultInt = Int(str1)! + Int(str2)!
        case "减":
            resultInt = Int(str1)! - Int(str2)!
        case "乘":
            resultInt = Int(str1)! * Int(str2)!
        case "除":
            resultInt = Int(str1)! / Int(str2)!
            
        default:
            return
        }
        self.result.text = "\(resultInt)"
    }
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

